package com.innerclass.closepackage.demo2;

public class TeachableProgrammer extends Programmer {

	public TeachableProgrammer() {
	}

	public TeachableProgrammer(String name) {
		super(name);
	}

	private void teach() {
		System.out.println(getName() + "在讲台上培训讲解...");
	}

	private class Closure implements Teachable {
		/*
		 * 非静态内部类回调外部类实现work方法，非静态内部类引用的作用 仅仅是向客户类提供一个回调外部类的途径
		 */
		public void work() {
			teach();
		}
	}

	// 返回一个非静态内部类的引用，允许外部类通过该非静态内部类引用来回调外部类的方法
	public Teachable getCallbackReference() {
		return new Closure();
	}

}
